package com.yanqu.road.server.cmd.activity.civil.cross;

import com.yanqu.road.entity.activity.ActivityConditionInfo;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityRewardResult;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ActivityProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.ActivityCivilRewardModule;
import com.yanqu.road.server.gameplayer.module.activity.RelationActivityModule;
import com.yanqu.road.server.manger.activity.RelationActivityMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_CROSS_ACTIVITY_RECEIVE_CIVIL_REWARD, desc = "领取通用全民奖励-跨服返回")
public class ActivityReceiveCivilRewardFromCrossCmd extends AbstractCommand {

    private int activityId;

    private int conditionType;

    private long value;

    private long activityUserId;

    private String params;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ActivityProto.CrossActivityReceiveCivilRewardToReqMsg reqMsg = ActivityProto.CrossActivityReceiveCivilRewardToReqMsg.parseFrom(packet.getBytes());
        conditionType = reqMsg.getConditionType();
        activityId = reqMsg.getActivityId();
        value = reqMsg.getValue();
        params = reqMsg.getParams();
        activityUserId = reqMsg.getActivityUserId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        //领取
        String reward = player.getModule(ActivityCivilRewardModule.class).receiveCivilReward(activityId, conditionType, activityUserId, value);
        ActivityProto.ActivityReceiveCivilRewardRespMsg.Builder respMsg = ActivityProto.ActivityReceiveCivilRewardRespMsg.newBuilder();
        respMsg.setRet(0);
        respMsg.setReward(reward);
        player.sendPacket(Protocol.U_ACTIVITY_RECEIVE_CIVIL_REWARD, respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
